<?php

if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chk = new CheckMode_3d($curruser['acl'], 5, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
unset($chk);
if (20 < $gametype)
{
    $_8hFlag = true;
}
else
{
    $_8hFlag = false;
}
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
if ($curruser['acl'] != 255)
{
    $userlist = GetUserList($curruser['id']);
    if ($userlist == "")
    {
        $ui->showErrorPage("<p>还没有建立会员！</p>");
        exit();
    }
}
require( "class_5h/RateConfig_5h.php" );
require( "class_5h/SRate_5h.php" );
$RateConfig_5h = new RateConfig_5h($gametype);
$SRate_5h = new SRate_5h($gametype);
$split = getvar("split");
$disk = getvar("disk");
$order = getvar("order");
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
$xyid = intval(getvar("xyid"));
if ($id == "")
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_5h->getLotto3DByDate($showday);
}
else
{
    $id = intval($id);
    $lottoData = $SRate_5h->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ($lottoData == "")
{
    $ui->showErrorPage("目前没有{$tblName}可以下注期数！");
    exit();
}
$startbet_3d = date("Hi", strtotime($lottoData['startbet']));
$stopbet_3d = date("Hi", strtotime($lottoData['stopbet']));
if ($stopbet_3d == "0000")
{
    $stopbet_3d = "2359";
}
$showday = date("Y-m-d", strtotime($lottoData['openbet']));
$split = isset($RateConfig_5h->splitArr[$split]) ? $split : 0;
$disk = isset($RateConfig_5h->diskArr[$disk]) ? $disk : "1";
$order = isset($RateConfig_5h->orderArr[$order]) ? $order : 0;
$playtype = isset($RateConfig_5h->playtypeArr02[$playtype]) ? $playtype : "r1";
if ($bid != "")
{
    $fieldsArr = array ($bid);
}
else
{
    $fieldsArr = $RateConfig_5h->playGroupArr02[$playtype];
}
$bidstr = "";
if ($bid == "")
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if (!in_array($bid, $RateConfig_5h->playGroupArr02[$playtype]))
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=" . $bid;
    $tpl->set("bid", $bid);
}
$menu_list_url = "";
$xyid = 1;
$tempUrl = "op.php?op=agent&fp=onlinebet_5h&id=" . $lottoData['id'] . "&gametype={$gametype}&playtype=";
$tempArr = array ();
$tempArr[] = $_8hFlag ? "" : "<th width='10%'>" . getOptionXYList($xyid, true, "", "xyid", "xyid") . "<span id='noxystr' class='noneRateRecord'>单一盘</span></th>";
$RateConfig_5h->playtypeArr02['r1all'] = "全部";
foreach ($RateConfig_5h->playtypeArr02 as $key => $val)
{
    $showUrl = $tempUrl . $key;
    if ($playtype == $key)
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' width='18%'><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("", $tempArr);
$tempStrInt = strtotime($lottoData['stopbet']);
$preArr = $SRate_5h->getLotto3DByIdPre($lottoData['id']);
$nextArr = $SRate_5h->getLotto3DByIdNext($lottoData['id']);
if ($preArr)
{
    $strPre = "<a href=\"op.php?op=agent&fp=onlinebet_5h&id=" . $preArr['id'] . "&gametype={$gametype}&playtype={$playtype}\">&lt&lt&lt上一期</a>";
}
else
{
    $strPre = "";
}
if ($nextArr)
{
    $strNext = "<a href=\"op.php?op=agent&fp=onlinebet_5h&id=" . $nextArr['id'] . "&gametype={$gametype}&playtype={$playtype}\">下一期&gt&gt&gt</a>";
}
else
{
    $strNext = "";
}
unset($preArr);
unset($nextArr);
$h = substr($stopbet_3d, 0, 2);
$m = substr($stopbet_3d, 2);
$tempStr = "{$showday} {$h}:{$m}:00";
$timetamp = systime();
$timetamplimit = strtotime($tempStr) - $timetamp;
$tpl->load("main", "onlinebet_5h.htm");
$tpl->set(array ("playtype" => $RateConfig_5h->playtypeArr02[$playtype], "menu_list_url" => $menu_list_url, "lotto_id" => $lottoData['id'], "round" => $lottoData['round'], "open" => $lottoData['open'], "strPre" => $strPre, "strNext" => $strNext, "timetamp" => $timetamp, "timetamplimit" => $timetamplimit, "playtypestr" => $playtype, "gametype" => $gametype, "gametypeStr" => $tblName, "jsLang" => $g_conf['language']));
$jslink = "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script>";
$jslink .= "var __roundID = " . $lottoData['id'] . ";";
$jslink .= "var __reloadCK = 0;";
$jslink .= "var now = new Date(1000 * {$timetamp});";
$jslink .= "var timestap = {$timetamplimit};";
$jslink .= "var myGlobalVal = {};";
$jslink .= "myGlobalVal.gametype = '{$gametype}';";
$jslink .= "myGlobalVal.lotto_id = " . $lottoData['id'] . ";";
$jslink .= "myGlobalVal.playtypestr = '{$playtype}';";
$jslink .= "myGlobalVal.open = '" . $lottoData['open'] . "';";
$jslink .= "myGlobalVal.reloadCK = '10';";
$jslink .= "var _playtype = 'r1';";
$jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别1</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
$jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别2</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
$jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别3</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
$jslink .= "</script>";
$jsScr = "";
if ($_8hFlag)
{
    $jsScr = "8h";
    if ($gametype == 24)
    {
        $jsScr = "pk10";
    }
}
$jslink .= "<script src='scr_5h/" . $g_conf['language'] . "/obet" . $jsScr . ".js'></script>";
$ui->set("jslink", $jslink);
$ui->header();
$tpl->show("main");
$ui->footer();
?>